/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/** *****************************************************************************************************
 *  \file     Dio_Cfg.h                                                                                 *
 *  \brief    This file contains interface header for DIO MCAL config.                                  *
 *                                                                                                      *
 * <table>                                                                                              *
 * <tr><th>Date                 <th>Version                                                             *
 * <tr><td>2025-03-25 19:03:22      <td>1.0.0 R                                            *
 * </table>                                                                                             *
 *******************************************************************************************************/

#ifndef DIO_CFG_H
#define DIO_CFG_H

#ifdef __cplusplus
extern "C" {
#endif

/********************************************************************************************************
 *                                      Include header files                                            *
 *******************************************************************************************************/
#include "Dio_Types.h"

 /**
 *  \addtogroup MCAL_DIO_MACRO DIO macro
 *  \{
 */

/********************************************************************************************************
 *                                 Global Macro definition                                              *
 *******************************************************************************************************/
 /**
 *  \name DIO software version macro
 *  \{
 */
/* autosar version information */
/** \brief  DIO driver autosar major version */
#define DIO_AR_RELEASE_MAJOR_VERSION      (0x04U)
/** \brief  DIO driver autosar minor version */
#define DIO_AR_RELEASE_MINOR_VERSION      (0x03U)
/** \brief  DIO driver autosar revision version */
#define DIO_AR_RELEASE_REVISION_VERSION   (0x01U)
/* semidrive driver information */
/** \brief  DIO driver vendor major version */
#define DIO_SW_MAJOR_VERSION              (0x03U)
/** \brief  DIO driver vendor minor version */
#define DIO_SW_MINOR_VERSION              (0x01U)
/** \brief  DIO driver vendor patch version */
#define DIO_SW_PATCH_VERSION              (0x00U)
/** \} */

 /**
 *  \name DIO service enable/diable defines
 *
 *  Pre-compile switches for enabling/disabling DIO MCAL APIs
 *  \{
 */
/** \brief Enable/Disable DEV error detection */
#define DIO_DEV_ERROR_DETECT                (STD_OFF)

/** \brief Enable/Disable Dio_GetVersionInfo() */
#define DIO_VERSION_INFO_API                (STD_ON)

/** \brief Enable/Disable Dio_FlipChannel() */
#define DIO_FLIP_CHANNEL_API                (STD_ON)

/** \brief Enable/Disable safety */
#define DIO_SAFETY_ENABLE                   (STD_ON)
/* \} */

/** \brief Enable/Disable Register value readback */
#define DIO_REG_READBACK_ENABLE             (STD_OFF)
/* \} */


#if defined(E3650)
#define APB_DIO_SF1_BASE (0xf81e0000UL)

#define APB_DIO_SF2_BASE (0xf81f0000UL)

#define APB_DIO_LP_BASE (0xf04b0000UL)

#endif /** #if defined(E3650) */

 /**
 *  \name DIO port/channel max defines
 *  \{
 */
/** \brief Max port ID */
#define DIO_MAXNOOFPORT                     ((Dio_PortType)12UL)
/** \brief Max channel ID */
#define DIO_MAXNOOFCHANNEL                  ((Dio_ChannelType)390UL)

/** \brief SF1 domain max channel ID */
#define DIO_SF1_CHANNEL_NUM 0xC0UL

/** \brief SF2 domain max channel ID */
#define DIO_SF2_CHANNEL_NUM 0x60UL

/** \brief LP domain max channel ID */
#define DIO_LP_CHANNEL_NUM 0x67UL

/** \brief SF1 domain max port ID */
#define DIO_SF1_PORT_NUM 0x6UL

/** \brief SF2 domain max port ID */
#define DIO_SF2_PORT_NUM 0x3UL

/** \brief LP domain max port ID */
#define DIO_LP_PORT_NUM 0x4UL
/* \} */

/**
 *  \name Symbolic name of DIO PORTs
 *
 *  This is symbolic name of DIO ports generated from configurator
 *  These defines map to physical GPIO register numbers.
 * \{
 */

/** \brief Symbolic name for GPIO REG #0x00 */
/**
 * Traceability       : SWSR_DIO_009 SWSR_DIO_010 SWSR_DIO_042
 */
#define DioConf_DioPort_DioPort_0  ((uint8)0x00U)
/* \} */

/** \brief Symbolic name for GPIO REG #0x06 */
/**
 * Traceability       : SWSR_DIO_009 SWSR_DIO_010 SWSR_DIO_042
 */
#define DioConf_DioPort_DioPort_6  ((uint8)0x06U)

/** \brief Shorter Symbolic name for GPIO channel #207 TOGGLE_LED2 */
/**
 * Traceability       : SWSR_DIO_009 SWSR_DIO_010 SWSR_DIO_042
 */
#define DioConf_DioChannel_TOGGLE_LED2 ((uint16)207U)
/* \} */

/** \brief Symbolic name for GPIO REG #0x0b */
/**
 * Traceability       : SWSR_DIO_009 SWSR_DIO_010 SWSR_DIO_042
 */
#define DioConf_DioPort_DioPort_11  ((uint8)0x0bU)

/** \brief Shorter Symbolic name for GPIO channel #358 TOGGLE_LED1 */
/**
 * Traceability       : SWSR_DIO_009 SWSR_DIO_010 SWSR_DIO_042
 */
#define DioConf_DioChannel_TOGGLE_LED1 ((uint16)358U)
/* \} */

/** \brief Symbolic name for GPIO REG #0x04 */
/**
 * Traceability       : SWSR_DIO_009 SWSR_DIO_010 SWSR_DIO_042
 */
#define DioConf_DioPort_DioPort_4  ((uint8)0x04U)

/** \brief Shorter Symbolic name for GPIO channel #146 GPIO_S18 */
/**
 * Traceability       : SWSR_DIO_009 SWSR_DIO_010 SWSR_DIO_042
 */
#define DioConf_DioChannel_GPIO_S18 ((uint16)146U)

/** \brief Shorter Symbolic name for GPIO channel #148 GPIO_S20 */
/**
 * Traceability       : SWSR_DIO_009 SWSR_DIO_010 SWSR_DIO_042
 */
#define DioConf_DioChannel_GPIO_S20 ((uint16)148U)

/** \brief Shorter Symbolic name for GPIO channel #151 GPIO_S23 */
/**
 * Traceability       : SWSR_DIO_009 SWSR_DIO_010 SWSR_DIO_042
 */
#define DioConf_DioChannel_GPIO_S23 ((uint16)151U)
/* \} */
/** \} */


/********************************************************************************************************
 *                                  Global Constant Declarations                                        *
 *******************************************************************************************************/
/** \brief Channel mask for enabled pins in the available ports */

/**
 * Traceability       : SWSR_DIO_074
 */
extern void (*Dio_InterruptNotification)(Dio_ChannelType channelId);

#ifdef __cplusplus
}
#endif

#endif /* DIO_CFG_H */

/* End of file */
